package com.zm.admin.zmeng.controller;

import com.zm.admin.utils.ResultBean;
import com.zm.admin.utils.ShellHandleUtil;
import com.zm.admin.zmeng.domain.ZmMonitor;
import com.zm.admin.zmeng.service.ZmMonitorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/***
 *
 * @Auther: MuYun
 * @Date: 2023/12/31 21:42
 * @Description： 资源监控相关接口
 *
 */
@RequestMapping("/monitor")
@RestController
@Slf4j
public class MonitorController {

    @Resource
    public ZmMonitorService zmMonitorService;

    @RequestMapping("/list")
    public ResultBean get(){
        ResultBean resultBean=new ResultBean();
        try{
            Map<String, Object> retMap = zmMonitorService.get();
            resultBean.setCode(ResultBean.CODE_SUCCESS).setData(retMap).setMsg("获取服务器数据成功");
        }catch (Exception e){
            log.error("{}",e);
            resultBean.setCode(ResultBean.CODE_ERROR).setMsg("获取服务器数据失败");
        }
        return resultBean;
    }

}
